package com.fuego.creditsystemcommodity.controller;


import com.fuego.creditsystemcommodity.service.IGoodOrderService;
import jakarta.annotation.Resource;
import org.example.dto.Result;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/good-order")
public class GoodOrderController {
    @Resource
    private IGoodOrderService goodOrderService;
    @PostMapping("goodInfo/{id}")
    public Result goodInfo(@PathVariable("id") Long goodId, @RequestParam("userId") Long userId, @RequestParam("amount") Long amount) {
        System.out.println("goodId: " + goodId + ", userId: " + userId+",amount " +amount);
        return goodOrderService.goodInfo(goodId, userId,amount);
    }

    @GetMapping("/list/allOrder")
    public Result queryAllOrder(@RequestParam("userId") Long userId) {
        return goodOrderService.queryAllOrders(userId);
    }

    @PostMapping("/refund")
    public Result refund(@RequestParam("orderId") Long orderId) {

        return goodOrderService.refund(orderId);
    }

}

